package store.lunangangster.nodeflow.parser.el;

import com.ql.util.express.ExpressRunner;
import store.lunangangster.nodeflow.common.BaseConstant;
import store.lunangangster.nodeflow.parser.el.operator.AnyOperator;
import store.lunangangster.nodeflow.parser.el.operator.DoOperator;
import store.lunangangster.nodeflow.parser.el.operator.ElseIfOperator;
import store.lunangangster.nodeflow.parser.el.operator.ElseOperator;
import store.lunangangster.nodeflow.parser.el.operator.ExitOperator;
import store.lunangangster.nodeflow.parser.el.operator.ForOperator;
import store.lunangangster.nodeflow.parser.el.operator.IfOperator;
import store.lunangangster.nodeflow.parser.el.operator.SwitchOperator;
import store.lunangangster.nodeflow.parser.el.operator.ThenOperator;
import store.lunangangster.nodeflow.parser.el.operator.ToOperator;
import store.lunangangster.nodeflow.parser.el.operator.WhenOperator;
import store.lunangangster.nodeflow.parser.el.operator.WhileOperator;
import store.lunangangster.nodeflow.rt.element.flow.IfFlow;
import store.lunangangster.nodeflow.rt.element.flow.LoopFlow;
import store.lunangangster.nodeflow.rt.element.flow.SwitchFlow;
import store.lunangangster.nodeflow.rt.element.flow.WhenFlow;

/**
 * ExpressRunner的封装类，在被创建时会进行初始化
 *
 * @author cwk
 * @version 1.0
 */
public class InitializedELRunner extends ExpressRunner {

  private void init() {
    this.addFunction(BaseConstant.EL_THEN, new ThenOperator());
    this.addFunction(BaseConstant.EL_WHEN, new WhenOperator());
    this.addFunction(BaseConstant.EL_IF, new IfOperator());
    this.addFunction(BaseConstant.EL_FOR, new ForOperator());
    this.addFunction(BaseConstant.EL_WHILE, new WhileOperator());
    this.addFunction(BaseConstant.EL_SWITCH, new SwitchOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_ANY, WhenFlow.class, new AnyOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_ELSEIF, IfFlow.class, new ElseIfOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_ELSE, IfFlow.class, new ElseOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_DO, LoopFlow.class, new DoOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_EXIT, LoopFlow.class, new ExitOperator());
    this.addFunctionAndClassMethod(BaseConstant.EL_TO, SwitchFlow.class, new ToOperator());
  }


  public InitializedELRunner() {
    this.init();
  }
}
